package com.sky.controller.admin;

import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController("adminSetmealController")
@RequestMapping("/admin/setmeal")
@Slf4j
@Api(tags = "套餐分类接口")
public class SetmealController {
    @Autowired
    private SetmealService setmealService;


    /**
     * 分页查询菜品套餐
     * @param dto
     * @return
     */
    @GetMapping("/page")
    @ApiOperation("分页查询")
    public Result pageSetmeal( SetmealPageQueryDTO dto){
        log.info("分页查询:{}", dto);
        return setmealService.pageSetmeal(dto);
    }

    /**
     * 新增分类
     * @return
     */
    @PostMapping
    @ApiOperation("新增套餐")
    public Result addSetmeal(@RequestBody SetmealDTO setmealDTO){
        return setmealService.addSetmeal(setmealDTO);
    }


    /**
     * id单一查询
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    @ApiOperation("id单一查询")
    public Result getById(@PathVariable Long id){
        log.info("根据id查询：{}",id);
        return setmealService.getById(id);
    }

    /**
     * 修改
     * @return
     */
    @PutMapping
    @ApiOperation("修改")
    public Result putSetmeal(@RequestBody SetmealDTO setmealDTO){
        return setmealService.putSetmeal(setmealDTO);
    }


    /**
     * 修改分类状态
     * @param status
     * @param id
     * @return
     */
    @PostMapping("/status/{status}")
    @ApiOperation("修改分类状态")
    public Result putStatus(@PathVariable Integer status,Long id){
        return setmealService.putStatus(status,id);
    }

    /**
     * 删除
     * @return
     */
    @DeleteMapping
    @ApiOperation(value = "删除方法")
    public Result delete(@RequestParam List<Long> ids){
        return  setmealService.delete(ids);
    }


}
